//
//  MRNestCollectionViewCell.m
//  MRDemo
//
//  Created by dingping on 2020/8/18.
//  Copyright © 2020 dingping. All rights reserved.
//

#import "MRNestCollectionViewCell.h"
#import "Masonry.h"
@interface MRNestCollectionViewCell ()

@property (nonatomic, strong) UIImageView *iconImageView;
@property (nonatomic, strong) UILabel *descLabel;

@end

@implementation MRNestCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        [self setupSubViews];
    }
    return self;
}


- (void)setupSubViews
{
    [self.contentView addSubview:self.iconImageView];
    [self.contentView addSubview:self.descLabel];
    
    CGFloat itemWidth = ([UIScreen mainScreen].bounds.size.width - (2 + 1) *15 - 1) / 2.0;

    [_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self.contentView);
        make.height.equalTo(@(itemWidth+50));
    }];
    
    [_descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.lessThanOrEqualTo(self.contentView);
        make.left.right.equalTo(self.contentView);
        make.top.equalTo(self->_iconImageView.mas_bottom).offset(10);
    }];
    
}


#pragma mark - initUI -
- (UIImageView *)iconImageView
{
    if(!_iconImageView) {
        _iconImageView = [[UIImageView alloc] init];
        _iconImageView.image = [UIImage imageNamed:@"soft"];
        _iconImageView.contentMode = UIViewContentModeScaleAspectFill;
        _iconImageView.clipsToBounds = YES;
        _iconImageView.layer.cornerRadius = 8;
    }
    return _iconImageView;
}

- (UILabel *)descLabel
{
    if(!_descLabel) {
        _descLabel = [[UILabel alloc]init];
        _descLabel.font = [UIFont systemFontOfSize:12];
        _descLabel.text = @"很好吃很可爱的呀是不是说呀哈哈哈哈哈哈";
        _descLabel.numberOfLines = 0;
    }
    return _descLabel;
}

@end
